# -*— coding: utf-8 -*-
#
# @Time : 2023/09/12 12:20
# @Author : LeeLU
# @File : chrome_driver.py
# @IDE : PyCharm
# @Email : luxuan888@vip.qq.com
# @Wechat : qianyongbuwan
from selenium import webdriver
# import undetected_chromedriver as uc
from seleniumbase import Driver

options = webdriver.ChromeOptions()
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument('--disable-infobars')  # 禁用浏览器正在被自动化程序控制的提示
options.add_argument('user-agent="Mozilla/5.0 (X11; Linux x86_64)   AppleWebKit/537.36 (KHTML, like Gecko) '
                     'Chrome/81.0.4044.122 Safari/537.36"')
# options.add_argument('headless')  #  LINUX时候可以开启  无头模式
# options.add_argument("--disable-gpu")  # 禁用gpu
# options.set_headles() # 无界面模式的另外一种开启方式
options.add_argument("--disable-blink-features=AutomationControlled")  # 去除特征值
options.add_experimental_option('excludeSwitches', ['enable-automation'])  # 开启实验性功能 反检测
# options.add_experimental_option('detach', True)  # 这两句控制的是执行完毕是否关闭chrome
# wd = webdriver.Chrome(options=options)  # 这句也是
wd = Driver(uc=True)
# script = '''object.defineProperty(navigator,'webdriver',{undefinedget: () => undefined})''' wd.execute_cdp_cmd(
# "page.addscriptToEvaluateonNewDocument", {"source": script}) #  反爬 window.navigator.webdriver的值=false
# wd=webdriver.Chrome()
# wd.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
#             "source": """
#             Object.defineProperty(navigator, 'webdriver', {
#               get: () => undefined
#             })
#             """
#         })

